AC_INIT([pantoute], [0.1], [gaudin.maxime@gmail.com])
AM_INIT_AUTOMAKE([foreign -Wall -Werror silent-rules])

AC_PROG_CC([clang gcc])
AC_PROG_CXX([clang++ g++])

AC_CONFIG_HEADERS([config.hpp])
AC_CONFIG_FILES([Makefile])

AC_LANG(C++)

#AM_SILENT_RULES([yes])

NEW_INCLUDE_PATH="-I/opt/local/include -I/opt/local/include/ -I./ -I./src/"

OPT_FLAGS="-O3"
CXXFLAGS="$CXXFLAGS $OPT_FLAGS $NEW_INCLUDE_PATH"
CFLAGS="$CFLAGS $OPT_FLAGS $NEW_INCLUDE_PATH" 
CPPFLAGS="$CPPFLAGS $OPT_FLAGS $NEW_INCLUDE_PATH"

LDFLAGS="$LDFLAGS -L/opt/local/lib"
LDFLAGS="$LDFLAGS -L/opt/local/lib"

# Vérification des headers de bases
AC_CHECK_HEADER([cstdio], [], [AC_MSG_ERROR([Missing header : cstdio])])
AC_CHECK_HEADER([cstdlib], [], [AC_MSG_ERROR([Missing header : cstdlib])])
AC_CHECK_HEADER([iostream], [], [AC_MSG_ERROR([Missing header : iostream])])
AC_CHECK_HEADER([cmath], [], [AC_MSG_ERROR([Missing header : cmath])])
AC_CHECK_HEADER([vector], [], [AC_MSG_ERROR([Missing header : vector])])
AC_CHECK_HEADER([fstream], [], [AC_MSG_ERROR([Missing header : fstream])])
AC_CHECK_HEADER([cmath], [], [AC_MSG_ERROR([Missing header : cmath])])
AC_CHECK_HEADER([climits], [], [AC_MSG_ERROR([Missing header : climits])])

# Intégration de Doxygen au processus et vérification
# de la possibilité de compiler en LaTeX et d'utiliser dot
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test -z "$DOXYGEN"; then 
  AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
else
  AC_CHECK_PROGS([DOT], [dot])
  if test -n "$DOT"; then
    AC_SUBST([HAVE_DOT], [YES]) 
  else
    AC_MSG_NOTICE([Diagrams must be generated by doxygen])
    AC_SUBST([HAVE_DOT], [NO]) 
  fi 

  AC_CHECK_PROGS([LATEX], [latex])
  AM_CONDITIONAL([HAVE_LATEX], [test -n "$LATEX"])
  if test -n "$LATEX"; then
    AC_SUBST([HAVE_LATEX], [YES]) 
  else
    AC_MSG_NOTICE([Only HTML doc will be available])
    AC_SUBST([HAVE_LATEX], [NO]) 
  fi 

fi
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([Doxyfile])])

AC_OUTPUT
